$(function($){
 
  var source =
            {
                //localdata: data,
                datafields:
                [
                    { name: 'time', type: 'data'},
                    { name: 'direction', type: 'string' },
                    { name: 'content', type: 'string' } 
                ],
                datatype: "array"
            };

            $("#channel_code").jqxGrid(
            {
                width: "100%",
				height: "593",
                source: source,
				theme:'black',
                columns: [
                  { text: '时间', datafield: 'time', width: 200 },
                  { text: '流向', datafield: 'direction', width: 50 },
                  { text: '报文', datafield: 'content'} 
                ]
            });
 
			$(window).load(function(){
				
			$(".dlgBody_layout").width(parseInt(($(window).width()-92)/120)*120);
			
 
			var scrool= $('#scroll_bd').tinyscrollbar();
	          $(".channel-item").on("click",function(){
				//alert("ok");showModalDialog
				  // window.showModalDialog("Default2.aspx?id=1","_blank",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=260,left=300,top=300');

                      $("#scroll_bd").hide();
				      $("#channel_code").show();

			  });
			});
		
		    $("#back_to_channel").on("click",function(){
					  $("#channel_code").hide();
					  $("#scroll_bd").show();
					  $("#channel_code").jqxGrid("clear");	
					//  alert($("#code_content .overview").html());		  
					});;
 
			     testcode=function(){
						 var datarow={"time":"123","direction":"ff","content":"ccccccccc"};
						 var commit = $("#channel_code").jqxGrid('addrow', null, datarow);
						 
						 var rows=$('#channel_code').jqxGrid('getrows');
					if(rows.length<200)
					{
					   var datarow = generatedata(1)[0];
						var commit = $("#channel_code").jqxGrid('addrow', null, datarow);
						var position = $('#channel_code').jqxGrid('scrollposition');
	
	
						 $('#channel_code').jqxGrid('scrolloffset', 5000, position.left);
						
					}else
					{
						  $('#channel_code').jqxGrid('clear');
					}
				};
				setInterval(testcode, 500);
		});//(jQuery);